package com.etc.service;

import com.etc.entity.User;
import com.etc.mapper.RegisterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class RegisterService {

    @Autowired
    private RegisterMapper registerMapper;

    public boolean regName(String username) {
        System.out.println("S"+username);
        User registerName = registerMapper.registerName(username);
//        System.out.println(registerName);
        if (registerName==null){
            return true;
        }else{
            return false;
        }
    }

    public boolean regPhone(String phone){
        System.out.println(phone);
        User registerPhone = registerMapper.registerPhone(phone);
        System.out.println(registerPhone);
        if (registerPhone==null){
            return true;
        }else{
            return false;
        }
    }

    public boolean regEmail(String email){

        User registerEmail = registerMapper.registerEmail(email);
        if (registerEmail==null){
            return true;
        }else{
            return false;
        }
    }

    public void saveRegister(User user){
        Date date = new Date();
        user.setPdate(date);
//        System.out.println(user);
        registerMapper.saveRegister(user);
    }
}
